package com.rockcent.third.helper;

import com.rockcent.mall.lib.helper.BaseCaptchaHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * Created by oyhk on 16/7/19.
 */
@Component
public class CaptchaHelper extends BaseCaptchaHelper {

    private final Logger log = LoggerFactory.getLogger(CaptchaHelper.class);

/*    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private SMSHelper smsHelper;
    @Autowired
    private ExecutorService commonExecutorService;
    @Autowired
    private Prop prop;*/
/*
    *//**
     * 发送短信
     * @param mobile 手机号码
     * @param key redis key
     * @param timeLeft 有效时间
     * @return
     *//*
    public String send(String mobile, String key, int timeLeft) {
        Object oCaptcha = redisTemplate.opsForValue().get(key);
        if (oCaptcha != null) {
            return String.valueOf(oCaptcha);
        }
        String captchaTemp = CommonUtils.getRandom6();
        redisTemplate.boundValueOps(key).set(captchaTemp);
        redisTemplate.expire(key, timeLeft, TimeUnit.SECONDS);
        //生产环境 或者 UAT 才会调用短信接口
        log.info("======================>msg send start");
        if (prop.env.equals(Config.UAT) || prop.env.equals(Config.PROD)) {
            log.info("======================>msg send env : {}",prop.env);
            commonExecutorService.execute(() -> {
                smsHelper.send(mobile, "您的验证码是:" + String.valueOf(captchaTemp));
            });
            return null;
        }
        log.info("======================>msg send end");
        return captchaTemp;
    }*/
}
